image: kernel.o k_entry.o memory.o screen.o system.o kernel.ld bootsect.bin
	ld -o kernel.bin -T kernel.ld k_entry.o kernel.o memory.o screen.o system.o
	cat bootsect.bin > image.img
	cat kernel.bin >> image.img

bootsect.bin: bootsect.asm
	nasm -o bootsect.bin bootsect.asm

k_entry.o: k_entry.asm
	nasm -f aout k_entry.asm -o k_entry.o

kernel.o: kernel.c memory.h
	gcc -O -nostdinc -fno-builtin -c kernel.c -o kernel.o

system.o: system.c system.h
	gcc -O -c system.c -o system.o

memory.o: memory.c memory.h
	gcc -O -c memory.c -o memory.o

screen.o: screen.c screen.h
	gcc -O -c screen.c -o screen.o

clean:
	rm *.o
	rm *.bin
	rm *.img


